mini.parse();
var url = bootPATH + "../frame/frame1/pages/";      	//路径前缀
var grid = mini.get("datagrid1");
//自动加载初始化方法
$(function () {
    init();
})
//初始化方法
function init() {
    $.ajax({
        url:ajaxUrl + '/data/findAlls.do',
        type:"POST",

        success:function (data) {
            console.log(data,"sssss");
            var data1=data;
            grid.setData(data1);
            $.ajax({
                url:ajaxUrl + '/data/findId.do',
                type: 'POST',
                success: function (data) {
                    var rowsArr=[];
                    console.log(data);
                    data.forEach(function (item) {
                        var row=grid.findRow(function (row) {
                            if(item.formListId==row.formListId)
                                return true
                        })
                        console.log(row);
                        rowsArr.push(row);
                    })
                    console.log(rowsArr);
                    grid.selects(rowsArr,true);

                },
                error: function (data) {
                    console.log("请求失败")
                }
            });
        },
        error:function () {
            console.log("失败");
        }
    })
}
function save(){
    var rows=grid.getSelecteds();
    var tableClassIdarr=[];
    console.log(rows);
    rows.forEach(function (item) {
        tableClassIdarr.push(item.formListId)
    })
    console.log(tableClassIdarr);
    tableClassIdarr=JSON.stringify(tableClassIdarr);
    console.log(tableClassIdarr);
    $.ajax({
        url:ajaxUrl + '/data/insert.do',
        type:"POST",
        data:{
            Id :tableClassIdarr
        },
        success:function (data) {
            console.log(data,"sssss");
            mini.alert(data.success);

        },
        error:function () {
            console.log("失败");
        }
    })

}
//上传附件
function upload(obj) {
    var files=obj.files;
    var formData=new FormData();
        for(var i=0;i<files.length;i++){
            formData.append("upfile[]",files[i]);
        }
        $.ajax({
            url: ajaxUrl+"/download/fileUpload2",
            type:"POST",
            data:{
                file:formData
            },
            cache:false,   //不设置缓存
            processData:false,   //不处理数据
            contentType:false  ,  //不设置内容类型
            success:function (data) {
                console.log(data)
            },
            error:function data() {
                console.log("444")
            }
        })
}